import vue from "@vitejs/plugin-vue";

import { ElementPlusResolver } from "unplugin-vue-components/resolvers";
import { PlusProComponentsResolver } from '@plus-pro-components/resolver'
import Components from 'unplugin-vue-components/vite'

import createAutoImport from "./auto-import";
import createSvgIcon from "./svg-icon";
import createCompression from "./compression";
import createSetupExtend from "./setup-extend";
import UnoCSS from 'unocss/vite'
import VueMacros from 'vue-macros/vite'

export default function createVitePlugins(viteEnv, isBuild = false) {
  const vitePlugins = [];
  vitePlugins.push(createAutoImport());
  vitePlugins.push(Components({
    resolvers: [ElementPlusResolver(), PlusProComponentsResolver()]
  }));
  vitePlugins.push(createSetupExtend());
  vitePlugins.push(createSvgIcon(isBuild));
  vitePlugins.push(UnoCSS());
  vitePlugins.push(VueMacros({
    plugins: {
      vue: vue()
    }
  }))
  isBuild && vitePlugins.push(...createCompression(viteEnv));
  return vitePlugins;
}
